

<html>
    <head>   
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Projects</title>
    </head>
    <body>
      <div class="undernav">
            <span class="menuButton"><g:link class="create_project" action="create">New Project</g:link></span>
        </div>
        <div class="body">
            <h1>Project List</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                            <g:sortableColumn property="name" title="Name" />
                            <g:sortableColumn property="startDate" title="Start Date" />
                            <g:sortableColumn property="endDate" title="End Date" />
                            <th>Status</th>
                            <th>Lab</th>
                            <th>Current Balance</th>
                            <th>Incoming Balance</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${projectInstanceList}" status="i" var="projectInstance">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                          <td>
                             <g:link action="show" id="${projectInstance.id}">
                                ${fieldValue(bean:projectInstance, field:'name')}
                             </g:link>
                          </td>
                          <td>
                            <g:link action="show" id="${projectInstance.id}">
                              <g:formatDate date="${projectInstance.startDate}" format="yyyy-MM-dd"/>
                            </g:link>
                          </td>

                          <td>
                            <g:link action="show" id="${projectInstance.id}">
                             <g:formatDate date="${projectInstance.endDate}" format="yyyy-MM-dd"/>
                            </g:link>
                          </td>

                          <td>
                            <g:link action="show" id="${projectInstance.id}">
                              ${projectInstance.calcStatus()}
                            </g:link>
                          </td>
                          <td>
                            <g:link action="show" id="${projectInstance.id}">
                              ${fieldValue(bean:projectInstance, field:'lab')}
                            </g:link>
                          </td>
                          <td>
                            <g:link action="show" id="${projectInstance.id}">
                              ${projectInstance.calcCurrentBalance()}
                            </g:link>
                          </td>
                          <td>
                           <g:link action="show" id="${projectInstance.id}">
                              ${projectInstance.calcIncomingBalance()}
                           </g:link>
                          </td>
                          <td>
                            <form method="Post" action="delete">
                                <input type="hidden" name="id" value="${projectInstance?.id}" />
                                <span class="button"><input type="submit"  value="" title="Delete" class="listDelete" onclick="return confirm('Are you sure?');" /></span>
                            </form>
                          </td>
                          
                        </tr>
                      
                    </g:each>
                    </tbody>                    
                </table>              
            </div>            
            <div class="paginateButtons">
                <g:paginate total="${projectInstanceTotal}" />
            </div>
            <div>
              <h2> Total Balance: ${totalCurrentBalance} SEK </h2>
            </div>
        </div>        
    </body>
</html>
